//------------------------------------------------------------------------------
//  characterjoint.cc
//  (C) 2008 Radon Labs GmbH
//------------------------------------------------------------------------------
#include "stdneb.h"
#include "characterjoint.h"

namespace Characters
{
using namespace Util;
using namespace Math;

//------------------------------------------------------------------------------
/**
*/
CharacterJoint::CharacterJoint() :
    poseTranslation(vector::nullvec()),
    poseRotation(quaternion::identity()),
    poseScale(1.0f, 1.0f, 1.0f),
    poseMatrix(matrix44::identity()),
    invPoseMatrix(matrix44::identity()),
    parentJointIndex(InvalidIndex),
	JointUniqueId(COLLADAFW::UniqueId::INVALID),
	parentJointUniqueId(COLLADAFW::UniqueId::INVALID)
{
    // empty
}

//------------------------------------------------------------------------------
/**
*/
CharacterJoint::~CharacterJoint()
{
    this->parentJointIndex = InvalidIndex;
    this->name.Clear();
}

//------------------------------------------------------------------------------
/**
*/
bool
CharacterJoint::WriteDataTag(Ptr<ToolkitUtil::ModelWriter>& writer)
{
	writer->BeginTag("Joint", 'JONT');
	writer->WriteInt(this->JointIndex);
	writer->WriteInt(this->parentJointIndex);
	writer->WriteFloat4(this->poseTranslation);
	writer->WriteFloat4(Math::float4(this->poseRotation.x(),this->poseRotation.y(),this->poseRotation.z(),this->poseRotation.w()));
	writer->WriteFloat4(this->poseScale);
	writer->WriteString(this->name.AsString());
	writer->EndTag();
	return false;
}

} // namespace Characters
